package com.mt.channel.service.impl;

import java.util.List;
import java.util.Map;


import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.mt.channel.api.service.IChannelApplyDropCourseService;
import com.mt.channel.entity.ChannelApplyDropCourseEntity;
import com.mt.channel.service.model.ChannelApplyDropCourseModel;
import com.mt.common.PagerInfo;
import com.mt.common.ServiceResult;
import com.mt.common.constants.BaseErrorConstants;
import org.springframework.stereotype.Service;

@Service
public class ChannelApplyDropCourseServiceImpl implements IChannelApplyDropCourseService {
    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ChannelApplyDropCourseServiceImpl.class);

    @Autowired ChannelApplyDropCourseModel channelApplyDropCourseModel;

    public ServiceResult<ChannelApplyDropCourseEntity> findInfo(Map<String, Object> params) {
        ServiceResult<ChannelApplyDropCourseEntity> result = null;
        try {
            result = channelApplyDropCourseModel.selectInfo(params);
        } catch (Exception e) {
            LOGGER.error("[ChannelApplyDropCourseServiceImpl][findInfo]：query findInfo occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询详情错误");
        }
        return result;
    }

    public ServiceResult<List<ChannelApplyDropCourseEntity>> findList(Map<String, Object> params,
            PagerInfo<?> pagerInfo) {
        ServiceResult<List<ChannelApplyDropCourseEntity>>
            result = new ServiceResult<List<ChannelApplyDropCourseEntity>>();
        try {
            result = channelApplyDropCourseModel.selectList(params, pagerInfo);
        } catch (Exception e) {
            LOGGER.error("[ChannelApplyDropCourseServiceImpl][findList]：query findList occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询列表错误");
        }

        return result;
    }

    public ServiceResult<Integer> doInsert(ChannelApplyDropCourseEntity channelApplyDropCourseEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = channelApplyDropCourseModel.insert(channelApplyDropCourseEntity);
        } catch (Exception e) {
            LOGGER.error("[ChannelApplyDropCourseServiceImpl][doInsert]：query doInsert occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "创建信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doUpdate(ChannelApplyDropCourseEntity channelApplyDropCourseEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = channelApplyDropCourseModel.updateRelate(channelApplyDropCourseEntity);
        } catch (Exception e) {
            LOGGER.error("[ChannelApplyDropCourseServiceImpl][doUpdate]：query doUpdate occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "更新信息错误.");
        }
        return result;
    }
}
